home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 505 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. From: tim@franck.Princeton.EDU (Tim Hollebeek)
  2. Message-ID: <4fvtk3$16j@cnn.Princeton.EDU>
  3. X-Original-Date: 15 Feb 1996 18:21:55 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 16 Feb 96 04:15:15 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Legal C++ code?
  9. Organization: Princeton University
  10. X-Newsreader: TIN [version 1.2 PL2]
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMSQE5uEDnX0m9pzZAQF7BwF+L6zrIaMaVjOx0SVAZ3Or91fk8rsEL/nt
  13.     9GvPVwJWlu3Orn2645zPoAjETikbSYBU
  14.     =IlFJ
  15.  
  16. Is the following legal C++ code?  g++ compiles it, but it doesn't link
  17. (undefined function Foo::foo()).  I'm suprised it compiles at all:
  18.  
  19. class Foo {
  20. public:
  21.     virtual int foo() = 0;
  22. };
  23.  
  24. class Bar : public Foo {
  25. public:
  26.     int foo() { return Foo::foo(); }
  27. };
  28.  
  29. int main() {
  30.     Bar bar;
  31.     bar.foo();
  32. }
  33.  
  34. ---------------------------------------------------------------------------
  35. Tim Hollebeek      | Disclaimer :=> Everything above is a true statement,
  36. <space for rent>   |                for sufficiently false values of true.
  37. Princeton Univ.    | email: tim@wfn-shop.princeton.edu
  38. -------------------| http://wfn-shop.princeton.edu/~tim (NEW! IMPROVED!)
  39. ---
  40. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  41.   Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  42.   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
  43.